//取消订单
$('.quxiaodingdan').on('click',function(){
	var eshopTradeId = $(this).attr("eshopTradeId");
	if(confirm("您确定取消此订单么？")) {
		$.ajax({
			type:"POST",
			url : "/eshop/trade/deleteEshopTrade.json",
			dataType : "json",
			data : {
				"eshopTradeId" :eshopTradeId
			},
			success : function(data) {
				if(data['code']=="200"){
					alert('订单已取消！');
					window.location.reload();
				}else if(data["code"] == "-200") {	
					alert('订单不存在！');
				}
			}
		})
	}
})

//删除完成的订单
$('.deleteOrder').on('click',function(){
	var tradeId = $(this).parent().attr("tradeId");
	console.log(tradeId);
	if(confirm("您确定取消此订单么？")) {
		$.ajax({
			type:"POST",
			url : "/eshop/trade/deleteTrade.json",
			dataType : "json",
			data : {
				"tradeId" :tradeId
			},
			success : function(data) {
				if(data['code']=="200"){
					alert('订单已取消！');
					window.location.reload();
				}else if(data["code"] == "-200") {	
					alert('订单不存在！');
				}
			}
		})
	}
})


//支付尾款
$('.paylast').on('click',function(){
	var tradeId = $(this).parent().attr("tradeId");
	var weikuan = $(this).attr("weikuan");
	if(confirm("是否支付尾款"+weikuan+"元？")) {
		console.log('111');
		$.ajax({
			type:"POST",
			url : "/eshop/trade/payLast.json",
			dataType : "json",
			data : {
				"tradeId" :tradeId
			},
			success : function(data) {
				if(data['code']=="200"){
					alert('已支付尾款成功！');
					window.location.reload();
				}else if(data["code"] == "-300") {	
					alert(data['message']);
				}else if(data["code"] == "-200") {	
					alert(data['message']);
				}
			}
		})
	}
})

//分页
//var tableHeight=$(".littleCr").height();
//alert(tableHeight);
//$(".littleCl").height(tableHeight);
//$(".littleCc").height(tableHeight);
 var pageCount=$(".pageCount").val();
    $(".tcdPageCode").createPage({
        pageCount:pageCount,
        current:$('.pageNo').val(),
        backFn:function(p){
//            var companyNameVar = $(".companyName").val();
//			if(companyNameVar!=null){
//				companyNameVar = encodeURI(encodeURI(companyNameVar));
//			}
        	window.location.href="/eshop/pcEshopList.html?pageNo="+p+"&qualification="+$("#qualification").val()+"&taxpayer="+$("#taxpayer").val()
        	+"&trademark="+$("#trademark").val()+"&price="+$("#price").val()+"&keyWord="+$("#keyWord").val()+"&orderBy="+$("#orderBy").val();
        }
    });
   